package com.meilingcloud.biobank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meilingcloud.biobank.domain.ShiftContainer;
import com.meilingcloud.biobank.mapper.ShiftContainerMapper;
import com.meilingcloud.biobank.service.IShiftContainerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 转移容器 Service业务层处理
 *
 * @author chenl
 * @date 2021-04-30
 */
@Service
public class ShiftContainerServiceImpl extends ServiceImpl<ShiftContainerMapper, ShiftContainer> implements IShiftContainerService {

    @Override
    public List<ShiftContainer> queryList(ShiftContainer shiftContainer) {
        LambdaQueryWrapper<ShiftContainer> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(shiftContainer.getShiftId())) {
            lqw.eq(ShiftContainer::getShiftId, shiftContainer.getShiftId());
        }
        if (shiftContainer.getContainerId() != null) {
            lqw.eq(ShiftContainer::getContainerId, shiftContainer.getContainerId());
        }
        if (shiftContainer.getOldParentId() != null) {
            lqw.eq(ShiftContainer::getOldParentId, shiftContainer.getOldParentId());
        }
        if (shiftContainer.getNewParentId() != null) {
            lqw.eq(ShiftContainer::getNewParentId, shiftContainer.getNewParentId());
        }
        if (StringUtils.isNotBlank(shiftContainer.getOldContainerLocation())) {
            lqw.eq(ShiftContainer::getOldContainerLocation, shiftContainer.getOldContainerLocation());
        }
        if (StringUtils.isNotBlank(shiftContainer.getNewContainerLocation())) {
            lqw.eq(ShiftContainer::getNewContainerLocation, shiftContainer.getNewContainerLocation());
        }
        if (shiftContainer.getOldContainerSort() != null) {
            lqw.eq(ShiftContainer::getOldContainerSort, shiftContainer.getOldContainerSort());
        }
        if (shiftContainer.getNewContainerSort() != null) {
            lqw.eq(ShiftContainer::getNewContainerSort, shiftContainer.getNewContainerSort());
        }
        return this.list(lqw);
    }
}
